﻿using IMark.DAO;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace IMark
{
    public partial class SoSanh : System.Web.UI.Page
    {
        public long IDLoaiSP = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            
            if(Request.QueryString["ID1"]!=null)
            {
                //long[] IDSP = Session["DanhGia"] as long[];
                long ID1 = long.Parse(Request.QueryString["ID1"]);
                SAN_PHAM sp1 = SanPhamModels.LaySanPhamTheoID(ID1);
                IDLoaiSP = sp1.IDLoaiSanPham;

                //SAN_PHAM sp2 = SanPhamModels.LaySanPhamTheoID(IDSP[1]);
                imgSP1.ImageUrl = "~/images/products/" + sp1.HINH_SAN_PHAM.First().Hinh;
                //imgSP2.ImageUrl = "~/images/products/" + sp2.HINH_SAN_PHAM.First().Hinh;
                
                lblTenSP1.Text = sp1.TenSanPham;
                //lblTenSP2.Text = sp2.TenSanPham;

                lblDanhGia1.Text = Utils.GenerateRation(sp1.DANH_GIA.ToList());
                //lblDanhGia2.Text = Utils.GenerateRation(sp2.DANH_GIA.ToList());

                lblGiaThanh1.Text = String.Format(CultureInfo.InvariantCulture,"{0:0,0}", sp1.DonGia)+"đ";
                //lblGiaThanh2.Text = String.Format(CultureInfo.InvariantCulture,"{0:0,0}", sp2.DonGia);

                if (sp1.NgayBatDau <= DateTime.Now && sp1.NgayKetThuc >= DateTime.Now)
                    lblGiamGia1.Text = String.Format(CultureInfo.InvariantCulture, "{0:0,0}", ((sp1.DonGia * sp1.GiamGia) / 100)) + "đ";
                else
                    lblGiamGia1.Text = "Không Giảm Giá!!!";
                //if (sp2.NgayBatDau <= DateTime.Now && sp2.NgayKetThuc >= DateTime.Now)
                    //lblGiamGia2.Text = String.Format(CultureInfo.InvariantCulture, "{0:0,0}", sp2.DonGia * (1 - ((sp2.DonGia * sp2.GiamGia) / 100)));
               // else
                    //lblGiamGia2.Text = "Không Giảm Giá!!!";

                lblThuongHieu1.Text = sp1.ThuongHieu;
                //lblThuongHieu2.Text = sp2.ThuongHieu;

                lblDacDiemNoiBat1.Text = sp1.MoTaTomTat;
                //lblDacDiemNoiBat2.Text = sp2.MoTaTomTat;
            }
        }

        
    }
}